'''定义一个类描述数字时钟。'''

from time import sleep
from os import system


class Clock:
    def __init__(self, h=0, m=0, s=0):
        self.h = h
        self.m = m
        self.s = s

    def run(self):
        self.s += 1
        if self.s == 60:
            self.s = 0
            self.m += 1
            if self.m == 60:
                self.h += 1
                self.m = 0
                if self.h == 24:
                    self.h = 0

    def show(self):
        print('Now is %02d:%02d:%02d' % (self.h, self.m, self.s))

def main():
    c = Clock(23, 58, 55)
    while 1:
        system('cls')
        c.show()
        c.run()
        sleep(0.1)

if __name__ == '__main__':
    main()